Skip to content

feat(noir): use noir libs #968

Merged
Maddiaa0 merged 14 commits intomasterfrom
md/noir-libs
Jul 5, 2023
Merged

feat(noir): use noir libs #968
Maddiaa0 merged 14 commits intomasterfrom
md/noir-libs

Conversation

@Maddiaa0
Copy link
Copy Markdown
Member

@Maddiaa0 Maddiaa0 commented Jul 5, 2023

Description

An issue has recently been fixed in the compiler that allows us to create more granular libs.
This pr migrates noir to use a library structure, creates two new ones, custom_notes and token_utils, removes code duplication and moves noir-aztec into the libs folder

contains a tiny bit of code shuffle ripped from here: #915 this was originally part of this pr but ive broken it up for easier review

Checklist:

  • I have reviewed my diff in github, line by line.
  • Every change is related to the PR description.
  • I have linked this pull request to the issue(s) that it resolves.
  • There are no unexpected formatting changes, superfluous debug logs, or commented-out code.
  • The branch has been merged or rebased against the head of its merge target.
  • I'm happy for the PR to be merged at the reviewer's next convenience.

@Maddiaa0 Maddiaa0 marked this pull request as ready for review July 5, 2023 09:58
@Maddiaa0 Maddiaa0 requested review from LHerskind and LeilaWang July 5, 2023 10:01

export const FUNCTION_SELECTOR_NUM_BYTES = 4;

export const MAPPING_SLOT_PEDERSEN_SEPARATOR = 4;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a place perhaps from cpp/bberg from where we are getting this value from? Maybe add a link to that there if in future we change this

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is from the constants.hpp file that this file already shadows

}

// Create a commitment to the amount
let note = TransparentNote::new(amount, secretHash);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if current_sender_balance < amount, we still seem to create a note?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #915


let thisAddress = inputs.call_context.storage_contract_address;
let mut args = [0; abi::MAX_ARGS];
// addUnshieldedBalance selector (in decimal)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment on how to calculate this easily plisssssss

Copy link
Copy Markdown
Contributor

@LHerskind LHerskind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor stuff, would be neat to fix the loops but looks good.

context.finish()
}

// Shield creates a way for a user to move tokens from the public context into the private context.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking this in #915

hash_bytes[322] = callerOnL1_bytes[30];
hash_bytes[323] = callerOnL1_bytes[31];

for i in 0..32 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in #915 it don't need as many separate loops.

let deadline_bytes = (self.deadline as Field).to_be_bytes(32);
let fee_bytes = (self.fee as Field).to_be_bytes(32);

for i in 0..32 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before with the loops.

NODE_OPTIONS=--no-warnings yarn ts-node --esm src/scripts/copy_output.ts $CONTRACT_NAME

echo "Formatting"
yarn run -T prettier -w ./src/examples/$CONTRACT_FOLDER.json
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noice Thats Nice GIF

}

// Create a commitment to the amount
let note = TransparentNote::new(amount, secretHash);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #915

@Maddiaa0 Maddiaa0 enabled auto-merge (squash) July 5, 2023 12:45
@Maddiaa0 Maddiaa0 merged commit 45cbe0e into master Jul 5, 2023
@Maddiaa0 Maddiaa0 deleted the md/noir-libs branch July 5, 2023 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants